import React from 'react';
import './style.css';
import { createStore } from 'redux';
import { reducer } from './reducer';
import { change } from './action';

const store = createStore(reducer);

export default class Basket extends React.Component{

    render(){
        this.state = store.getState();
        console.log(this.state,'000')
        var num = this.state?this.state.num:0;
        console.log(num,'===');
        return(
            <article className="lin_box">
                <div className="lin_screen">
                    1
            {num}
                </div>
                <div className="lin_btn">
                    <button onClick={this.add.bind(this)}>add</button>
                    <button onClick={this.jian.bind(this)}>jian</button>
                </div>
            </article>
        )
    }
    add(){
        console.log(1);
        store.dispatch({ type: 'ADD' });
    }
    jian(){
        console.log(2);
        store.dispatch({ type: 'JIAN' });
    }
}
// render();
// store.subscribe(render);